
"""


:param
lenght 队列定长
"""


class Queue(object):
    """队列"""

    def __init__(self,length):
        self.items = []
        self.length=length

    def is_empty(self):
        return self.items == []

    def enqueue(self, item):
        """进队列"""
        self.items.insert(0, item)
        if self.size()>self.length:
            self.dequeue()

    def dequeue(self):
        """出队列"""
        return self.items.pop()

    def size(self):
        """返回大小"""
        return len(self.items)

    def show(self):
        print(self.items)


    def sum(self):
        return sum(self.items)